package day21;
/**
装饰者设计模式步骤：
	1. 在装饰类的内部，维护一个被装饰类的引用
	2. 让装饰类继承同一个父类或者父接口
 */

interface Worker{
	public void work();
}

class Son implements Worker{
	Worker woker;

	@Override
	public void work() {
		System.out.println("画画");
	}
}

class Mother implements Worker{
	Worker worker;

	public Mother(Worker worker) {
		super();
		this.worker = worker;
	}

	@Override
	public void work() {
		worker.work();	//继承 woker 的 work 方法
		System.out.println("上色");//装饰
	}
}

class Father implements Worker{
	Worker worker;

	public Father(Worker worker) {
		super();
		this.worker = worker;
	}

	@Override
	public void work() {
		worker.work();	//继承 woker 的 work 方法
		System.out.println("上画框");	//装饰
	}
}

public class DecoratorPattern_eg {

	public static void main(String[] args) {
		Son son = new Son();
//		son.work();
		Mother mother = new Mother(son);
//		mother.work();
		Father father = new Father(mother);
		father.work();
	}

}
